I am learning JavaScript Function Hoisting, which says "the declaration of functions are moved to the top of their scope". Then I read the definition of "scope" from this doc, it says "A function serves as a closure in JavaScript, and thus creates a scope". So does it mean any functions declared inside a function are moved to the top of that function? I use the following example to test:
foo();
function foo() {
console.log(too);
console.log(zoo);
{
function too() {console.log("too");}
}
function zoo() {console.log("zoo");}
}
The out put is
undefined
ƒ zoo() {console.log("zoo");}
So obviously the declaration of too is not moved to the top of foo. It is actually moved to the top of the block statement inside foo. So what is the exact definition of "scope" when we are talking about function hoisting in JavaScript?